package gui;


import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Toolkit;

import javax.swing.JFrame;

/**
 * Displays a panel on a new frame.
 * @author s0212002
 *
 */
public class ComponentFrame extends JFrame {
	
	public ComponentFrame(String name, Component componentToDisplay,int close){
		super(name);
		this.setDefaultCloseOperation(close);
		this.add(componentToDisplay,BorderLayout.CENTER);
		setMinimumSize(componentToDisplay.getMinimumSize());
		setPreferredSize(componentToDisplay.getPreferredSize());
		setSize(componentToDisplay.getPreferredSize());
		setVisible(true);
	}
	

	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	

	
	
	public static Dimension getScreenSize(){
		Toolkit t = Toolkit.getDefaultToolkit();
		return new Dimension(t.getScreenSize().width,t.getScreenSize().height - 50);
	}
	
	public static void showFrame(String name, Component component){
		ComponentFrame tmp = new ComponentFrame(name, component,JFrame.EXIT_ON_CLOSE);
		
	}

}
